home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Pascal / Snippets / PNL Libraries / Libraries / SpriteWorld / SpriteWorld files / Utils C / SWApplication.c next >
Encoding:
Text File  |  1996-10-24  |  2.6 KB  |  115 lines  |  [TEXT/KAHL]

  1. ///--------------------------------------------------------------------------------------
  2. //    SWApplication.c
  3. //
  4. //    Portions are Copyright: © 1993 Tony Myles, All rights reserved worldwide.
  5. ///--------------------------------------------------------------------------------------
  6.  
  7.  
  8. #include <GestaltEqu.h>
  9. #include "SWApplication.h"
  10.  
  11.  
  12. ///--------------------------------------------------------------------------------------
  13. //    Initialize
  14. ///--------------------------------------------------------------------------------------
  15.  
  16. pascal void Initialize(short numberOfMasters)
  17. {
  18.     EventRecord tempEvent;
  19.  
  20.     MaxApplZone();
  21.  
  22.     while (numberOfMasters--)
  23.     {
  24.         MoreMasters();
  25.     }
  26.  
  27.     InitGraf(&qd.thePort);
  28.     InitFonts();
  29.     InitWindows();
  30.     InitMenus();
  31.     TEInit();
  32.     InitDialogs(NULL);
  33.     InitCursor();
  34.     FlushEvents(everyEvent, 0);
  35.  
  36.     (void)EventAvail(everyEvent, &tempEvent);
  37.     (void)EventAvail(everyEvent, &tempEvent);
  38.     (void)EventAvail(everyEvent, &tempEvent);
  39. }
  40.  
  41.  
  42. ///--------------------------------------------------------------------------------------
  43. //    ErrorAlert
  44. ///--------------------------------------------------------------------------------------
  45.  
  46. pascal void ErrorAlert(OSErr err, short errorStringIndex)
  47. {
  48.     Str255 messageString, errorString;
  49.  
  50.     GetIndString(messageString, kErrorStringListResID, errorStringIndex);
  51.  
  52.     if (messageString[0] == 0)
  53.     {
  54.         BlockMove(kSeriousDamageString, messageString, sizeof(kSeriousDamageString));
  55.     }
  56.  
  57.     NumToString(err, errorString);
  58.  
  59.     ParamText(messageString, errorString, "\p", "\p");
  60.  
  61.     (void)StopAlert(kErrorAlertResID, NULL);
  62. }
  63.  
  64.  
  65. ///--------------------------------------------------------------------------------------
  66. //    FatalError
  67. ///--------------------------------------------------------------------------------------
  68.  
  69. pascal void FatalError(OSErr err)
  70. {
  71.     if (err != noErr)
  72.     {
  73.         if (err == memFullErr)
  74.         {
  75.             ErrorAlert(err, kOutOfMemStringIndex);
  76.         }
  77.         else
  78.         {
  79.             ErrorAlert(err, kFatalErrorStringIndex);
  80.         }
  81.         ExitToShell();
  82.     }
  83. }
  84.  
  85.  
  86. ///--------------------------------------------------------------------------------------
  87. //    CantFindResource
  88. ///--------------------------------------------------------------------------------------
  89.  
  90. pascal void CantFindResource(void)
  91. {
  92.     OSErr err;
  93.  
  94.     err = ResError();
  95.  
  96.     if (err == noErr)
  97.     {
  98.         err = resNotFound;
  99.     }
  100.  
  101.     ErrorAlert(err, kCantFindResourceStringIndex);
  102.  
  103.     ExitToShell();
  104. }
  105.  
  106.  
  107. ///--------------------------------------------------------------------------------------
  108. //    CantRunOnThisMachine
  109. ///--------------------------------------------------------------------------------------
  110.  
  111. pascal void CantRunOnThisMachine(void)
  112. {
  113.     (void)StopAlert(kCantRunAlertResID, NULL);
  114. }
  115.